<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>身份证号码解析</title>
<style>
    #showJP {
        margin-top: 20px;
        font-size: 20px;
        font-weight: bold;
    }
    body{
        text-align: center;
    }
</style>
</head>
<body>

<label for="idCard">请输入身份证号码：</label>
<input type="text" id="idCard" placeholder="请输入18位身份证号码">
<button onclick="parseIdCard()">解析</button>

<div id="birthday"></div>

<script>
    function parseIdCard() {
        let idCard = document.getElementById('idCard').value;
        if (idCard.length !== 18) {
            alert('请输入18位身份证号码！');
            return;
        }
        let birthYear = idCard.slice(6, 10);
        let birthMonth = idCard.slice(10, 12);
        let birthDay = idCard.slice(12, 14);
        let birthday = `${birthYear}年${birthMonth}月${birthDay}日`;
        document.getElementById('birthday').innerText = birthday;
    }
</script>

</body>
</html>